/**
 * 热门分类 js  api
 */
import request from "@/utils/request";

// 获取热门分类树
export function queryHotClassifyTree(parentOid = "") {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/kstbHotClassify/queryHotClassifyTree?parentOid=${parentOid}`,
    method: "get"
  });
}

// 分页查询数据
export function getTableInfo(query) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/kstbHotClassify/pageList",
    method: "get",
    params: query
  });
}

/**
 * 根据hotClassifyCode 查询是否存在
 * @param {*} hotClassifyCode
 */
export function hasExistByHotClassifyCode(hotClassifyCode) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/kstbHotClassify/hasExistByHotClassifyCode/${hotClassifyCode}`,
    method: "post"
  });
}

/**
 * 保存热门分类
 * @param {*} data
 */
export function saveOrUpdate(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/kstbHotClassify/saveOrUpdate`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 根据id来查询数据
 * @param {*} id
 */
export function getById(id = "") {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/kstbHotClassify/getById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

// 根据id删除
export function deleteById(oid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/kstbHotClassify/delete/${oid}`,
    method: "post"
  });
}

/**
 * 根据id批量删除
 * @param {*} ids
 */
export function batchDel(ids) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/kstbHotClassify/batchDel`,
    method: "get",
    params: {
      ids: ids
    }
  });
}

/**
 * 根据主键oid查询
 * @param {*} id
 * @returns
 */
export function getOne(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/kstbHotClassify/getOne/${id}`,
    method: "get"
  });
}

/**
 * 根据业务主键来查询唯一的数据
 */
export function queryByOid(oid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/kstbHotClassify/queryByOid/${oid}`,
    method: "post"
  });
}
